package com.tanhua.app.controller;

import com.tanhua.app.Service.TanhuaService;
import com.tanhua.model.dto.RecommendUserDto;
import com.tanhua.model.vo.NearUserVo;
import com.tanhua.model.vo.PageResult;
import com.tanhua.model.vo.TodayBest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/tanhua")
public class TanhuaController {
    @Autowired
    private TanhuaService tanhuaService;

//    今日佳人
//    GET   /tanhua/todayBest
    @GetMapping("/todayBest")
    public ResponseEntity todayBest(){
        TodayBest vo = tanhuaService.todayBest();
        return ResponseEntity.ok(vo);
    }

//    推荐朋友
//    GET   /tanhua/recommendation
    @GetMapping("/recommendation")
    public ResponseEntity recommendation(RecommendUserDto dto) {
        PageResult pageResult = tanhuaService.recommendation(dto);
        return ResponseEntity.ok(pageResult);
    }

//    查看佳人信息
//    GET   /tanhua/:id/personalInfo
    @GetMapping("/{id}/personalInfo")
    public ResponseEntity personalInfo(@PathVariable("id")Long userId){
        TodayBest vo = tanhuaService.personalInfo(userId);
        return ResponseEntity.ok(vo);
    }

//    查询陌生人问题
//    GET   /tanhua/strangerQuestions
    @GetMapping("/strangerQuestions")
    public ResponseEntity strangerQuestions(Long userId){
        String question = tanhuaService.strangerQuestions(userId);
        return ResponseEntity.ok(question);
    }

//    回复陌生人问题
//    POST  /tanhua/strangerQuestions
    @PostMapping("/strangerQuestions")
    public ResponseEntity strangerQuestions(@RequestBody Map map){
        String obj =map.get("userId").toString();
        Long userId = Long.valueOf(obj);
        String reply = (String) map.get("reply");
        tanhuaService.replyQuestions(userId,reply);
        return ResponseEntity.ok(null);
    }

//    探花-左滑右滑
//    GET   /tanhua/cards
    @GetMapping("/cards")
    public ResponseEntity queryCardsList(){
        List<TodayBest> list = tanhuaService.queryCardsList();
        return ResponseEntity.ok(list);
    }

//    探花=喜欢
//    GET   /tanhua/:id/love
    @GetMapping("/{id}/love")
    public ResponseEntity likeUser(@PathVariable("id") Long likeUserId) {
        tanhuaService.likeUser(likeUserId);
        return ResponseEntity.ok(null);
    }

//    探花-不喜欢
//    GET   /tanhua/:id/unlove
    @GetMapping("/{id}/unlove")
    public ResponseEntity notLikeUser(@PathVariable("id") Long notLikeUserId){
        tanhuaService.notLikeUser(notLikeUserId);
        return ResponseEntity.ok(null);
    }

//    搜附近
//    GET   /tanhua/search
    @GetMapping("/search")
    public ResponseEntity queryNearUser(String gender,@RequestParam(defaultValue = "2000") String distance){
        List<NearUserVo> list = tanhuaService.queryNearUser(gender,distance);
        return ResponseEntity.ok(list);
    }
}
